package com.leetcode.partition16;

import java.io.*;
import java.util.PriorityQueue;

/**
 * @author `RKC`
 * @date 2022/2/3 18:27
 */
public class LC1514概率最大的路径 {

    private static final int N = (int) (1e4 + 10), M = 4 * N, INF = 0x3f3f3f3f;
    private static int[] h = new int[N], e = new int[M], ne = new int[M];
    private static double[] w = new double[M];

    private static int n = 0, idx = 1;
    private static double[] dist = new double[N];
    private static boolean[] st = new boolean[N];
    private static PriorityQueue<Node> heap = new PriorityQueue<>(N, (o1, o2) -> Double.compare(o2.w, o1.w));

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] ss = reader.readLine().split(" ");
        int n = Integer.parseInt(ss[0]), m = Integer.parseInt(ss[1]), start = Integer.parseInt(ss[2]), end = Integer.parseInt(ss[3]);
        int[][] edges = new int[m][2];
        double[] succProb = new double[m];
        for (int i = 0; i < m; i++) {
            ss = reader.readLine().split(" ");
            int a = Integer.parseInt(ss[0]), b = Integer.parseInt(ss[1]);
            edges[i] = new int[]{a, b};
        }
        ss = reader.readLine().split(" ");
        for (int i = 0; i < m; i++) succProb[i] = Double.parseDouble(ss[i]);
        writer.write(String.format("%.5f\n", maxProbability(n, edges, succProb, start, end)));
        writer.flush();
    }

    public static double maxProbability(int _n, int[][] edges, double[] succProb, int start, int end) {
        n = _n;
        for (int i = 0; i < edges.length; i++) {
            int a = edges[i][0], b = edges[i][1];
            double c = succProb[i];
            add(a, b, c);
            add(b, a, c);
        }
        dist[start] = 1;
        heap.add(new Node(start, 1));
        while (!heap.isEmpty()) {
            Node cur = heap.poll();
            int u = cur.u;
            if (st[u]) continue;
            st[u] = true;
            for (int i = h[u]; i != 0; i = ne[i]) {
                int v = e[i];
                if (dist[v] < dist[u] * w[i]) {
                    dist[v] = dist[u] * w[i];
                    heap.add(new Node(v, dist[v]));
                }
            }
        }
        return dist[end];
    }

    private static void add(int a, int b, double c) {
        e[idx] = b;
        ne[idx] = h[a];
        h[a] = idx;
        w[idx++] = c;
    }

    private static class Node {
        private int u;
        private double w;

        public Node(int _u, double _w) {
            u = _u;
            w = _w;
        }
    }
}
